//
// Created by henry on 2025/11/7.
//
#include "admin.h"
#include "student/menu_canteen.h"

//进入后端
int admin_entry(){
    printf("欢迎进入后端系统!\n");
    admin_login_menu();

    admin_menu();
}
//后端菜单
int admin_menu(){

    printf("管理列表\n");
    while (1) {
        printf("1.查看菜单 2.添加菜品 3.修改菜品 4.删除菜品 5.用户信息查询 6.用户信息注册 7.用户信息删除 8.用户订单查询 9.返回上级\n");
        int choose;
//        Menu menu;
//        Menu * m=& menu;
        if (scanf("%d", &choose) != 1) {
            printf("输入无效，请输入一个数字！\n");
            choose = 0; // 给一个无效值，让 switch 进入 default
        }
        while (getchar() != '\n');

        switch (choose) {
            case 1:
                menu_query();
                break;
            case 2:
                menu_insert();
                break;
            case 3:
                menu_update_ui(db);
                break;
            case 4:
                menu_delete_ui(db);
                break;
            case 5:
            {const char *stu_user = "SELECT id, username, balance, number FROM stu_user;";
                query_stu_user(stu_user);}
                break;
            case 6:
                front_user_register();
                break;
            case 7:
                user_delete_ui(db);
                break;
            case 8:
                query_all_orders();
                break;
            case 9:
                printf("返回上级菜单...\n");
                return 0;
            default:
                break;
        }
    }
}

